# import requests
# url = 'https://www.baidu.com/s?wd=python'
# #构建请求头字典
# headers = {'user-agent':'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/127.0.0.0 Safari/537.36 Edg/127.0.0.0'}
# response = requests.get(url,headers=headers)
#
# with open('baidu.html','wb')as f:
#     f.write(response.content)

import requests
url = 'https://www.baidu.com/s?w'
# 构建请求头字典
headers = {'user-agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/127.0.0.0 Safari/537.36 Edg/127.0.0.0'}
# 构建参数字典
data = {
    'wd': 'python'
}
response = requests.get(url,headers=headers)

print(response.url)
with open('baidu1.html', 'wb')as f:
    f.write(response.content)